package ace.module.mail.address.sdk.core.feign.impl;

import ace.cmp.core.model.PageResultDto;
import ace.cmp.core.model.R;
import ace.cmp.openfeign.security.oauth2.core.config.FeignInternalServerOauth2SecurityConfig;
import ace.module.common.api.annotation.ApiRemoteProxyPriority;
import ace.module.common.api.model.input.TenantAndAppTypeInput;
import ace.module.mail.address.api.model.dto.MadMailAddressDto;
import ace.module.mail.address.api.model.input.mailaddress.MadMailAddressAddInput;
import ace.module.mail.address.api.model.input.mailaddress.MadMailAddressModifyInput;
import ace.module.mail.address.api.model.input.mailaddress.MadMailAddressSearchInput;
import ace.module.mail.address.sdk.core.constant.SdkConstant;
import ace.module.mail.address.sdk.core.feign.MadMailAddressFeignApi;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * 邮寄地址 rpc feign.
 *
 * @author Caspar
 */
@FeignClient(
    name = "${spring.cloud.openfeign.client.config.madMailAddressFeign.name:" + SdkConstant.FEIGN_SERVICE_NAME + "}",
    contextId = "madMailAddressFeign",
    path = MadMailAddressFeign.PATH,
    configuration = FeignInternalServerOauth2SecurityConfig.class,
    primary = false
)
@ApiRemoteProxyPriority
public interface MadMailAddressFeign extends MadMailAddressFeignApi {

  String PATH = "${spring.cloud.openfeign.client.config.madMailAddressFeign.path:/mail-address/mad-mail-address/rpc}";

  @PostMapping("/search")
  R<PageResultDto<MadMailAddressDto>> search(
      @Valid @NotNull @RequestBody MadMailAddressSearchInput input);

  @PostMapping("/addByAppOutId")
  R<Long> addByAppOutId(@Valid @NotNull @RequestBody MadMailAddressAddInput input);

  @PostMapping("/modifyByAppOutId")
  R<Void> modifyByAppOutId(@Valid @NotNull @RequestBody MadMailAddressModifyInput input);

  @PostMapping("/getByTenantAndAppTypeAndId")
  R<MadMailAddressDto> getByTenantAndAppTypeAndId(
      @Valid @NotNull @RequestBody TenantAndAppTypeInput<Long> input);
}